package io.lvdaxian.handwriting.lambda;

import io.lvdaxian.handwriting.po.User;
import org.junit.Test;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * collect 相关的逻辑
 *
 * @author lihh
 */
public class CollectTest {
  
  @Test
  public void testCase001() {
    List<User> users = Stream.of("1", "2", "3").map(l -> User.builder().age(Integer.valueOf(l)).build()).collect(Collectors.toList());
    users.forEach(System.out::println);
  }
  
  @Test
  public void test002() {
    Integer sum = Stream.of(1, 2, 3).reduce(10, (a, b) -> a * b);
    System.out.println("sum = " + sum);
  }
}
